<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据面板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">{% load static %}
    <link rel="icon" href="{% static 'layuimini/images/favicon.ico' %}">
    <link rel="stylesheet" href="{% static 'layuimini/lib/layui-v2.5.5/css/layui.css' %}" media="all">
    <link rel="stylesheet" href="{% static 'layuimini/css/layuimini.css' %}" media="all">
    <link rel="stylesheet" href="{% static 'layuimini/lib/font-awesome-4.7.0/css/font-awesome.min.css' %}" media="all">
    <style>
        .layui-top-box {padding:40px 20px 20px 20px;color:#fff}
        .panel {margin-bottom:17px;background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
        .panel-body {padding:15px}
        .panel-title {margin-top:0;margin-bottom:0;font-size:14px;color:inherit;}
        .label {display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top: .3em;}
        .layui-red {color:red}
        .main_btn > p {height:40px;}
        .amount {font-size:400%;margin-top:10px;margin-bottom:10px;text-align:center;}
        .layui-field-title {color: black;}
    </style>
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main layui-top-box">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>当前状态</legend>
                </fieldset>
            </div>
            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-blue">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>活动任务</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.active_task }}</h1>
                                <small>总任务数为{{ statistics.task }}</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-green">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>批量任务</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.active_batch_task }}</h1>
                                <small>总批量任务数为{{ statistics.batch_task }}</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-cyan">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>当前项目</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.project }}</h1>
                                <small>当前项目数量</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-red">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>当前记录</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.record }}</h1>
                                <small>当前记录数量</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-orange">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>记录类型</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.record_type }}</h1>
                                <small>当前记录类型数量</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md2">
                <div class="col-xs-6 col-md-2">
                    <div class="panel layui-bg-gray">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h5>可用工具</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins amount">{{ statistics.tool }}</h1>
                                <small>当前工具数量</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md12">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>新增历史</legend>
                </fieldset>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">
                    <div id="echarts-records" style="width:99%; min-height:300px"></div>
                </div>
                </div>
            </div>

        </div>
    </div>
</div>
</div>
</div>
<script src="{% static 'layuimini/lib/layui-v2.5.5/layui.js' %}" charset="utf-8"></script>
<script src="{% static 'layuimini/js/lay-config.js' %}" charset="utf-8"></script>
<script>
    layui.use(['layer','echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;

        var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
        $.get( "/api/graph", function(data) {
            if (data.code != 0) {
                layer.msg('曲线图数据加载失败！');
            } else {
                var series = new Array();
                for (key in data.msg.data) {
                    series.push(
                        {
                            name: key,
                            type: 'line',
                            data: data.msg.data[key]
                        }
                    );
                }
                var optionRecords = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: Object.keys(data.msg.data)
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: data.msg.date_list
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: series
                };
                echartsRecords.setOption(optionRecords);
            }
        });

        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsRecords.resize();
        }

    });
</script>
</body>
</html>
